/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package lolbuilder.mainClasses;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.DefaultListModel;
import javax.swing.JList;
import javax.swing.ListModel;
import javax.swing.event.ListDataListener;
import lolbuilder.Champions.Impl.Caster;
import lolbuilder.Champions.Impl.GenericChamp;
import lolbuilder.Champions.Interf.DummyChamp;
import lolbuilder.Items.Interf.ItemsSuper;
import lolbuilder.build.Build;
import lolbuilder.calculation.*;
import lolbuilder.masteries.BestDpsMasteriesChoose;
import lolbuilder.params.Duo;
import lolbuilder.params.Parameters;
import lolbuilder.runes.RunesCompoCalculator;

/**
 *
 * @author chocoboSan
 */
public class AppliGraphique extends javax.swing.JFrame {
    ArrayList<Build> builds=new ArrayList<Build>();
    ArrayList<Build> dispoBuilds=new ArrayList<Build>();

    /**
     * Creates new form AppliGraphique
     */
    public AppliGraphique() {
        initComponents();
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jTabbedPane2 = new javax.swing.JTabbedPane();
        jPanel3 = new javax.swing.JPanel();
        jCheckBoxBBAD = new javax.swing.JCheckBox();
        jButton3 = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jButton4 = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTextArea1 = new javax.swing.JTextArea();
        jCheckBoxBBB = new javax.swing.JCheckBox();
        jLabel4 = new javax.swing.JLabel();
        jCheckBoxBBADLS = new javax.swing.JCheckBox();
        jCheckBoxBBTAD = new javax.swing.JCheckBox();
        jLabel13 = new javax.swing.JLabel();
        jPanel4 = new javax.swing.JPanel();
        jButton2 = new javax.swing.JButton();
        jButton5 = new javax.swing.JButton();
        jLabel2 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jLabel9 = new javax.swing.JLabel();
        jLabel10 = new javax.swing.JLabel();
        jTextField2 = new javax.swing.JTextField();
        jTextField3 = new javax.swing.JTextField();
        jTextField4 = new javax.swing.JTextField();
        jTextField5 = new javax.swing.JTextField();
        jTextField6 = new javax.swing.JTextField();
        jTextField7 = new javax.swing.JTextField();
        jButton6 = new javax.swing.JButton();
        jLabel11 = new javax.swing.JLabel();
        jLabel12 = new javax.swing.JLabel();
        jTextField8 = new javax.swing.JTextField();
        jTextField9 = new javax.swing.JTextField();
        jPanel1 = new javax.swing.JPanel();
        jButton7 = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setResizable(false);

        jCheckBoxBBAD.setSelected(true);
        jCheckBoxBBAD.setText("Best Build Ad");

        jButton3.setText("Launch");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });

        jLabel3.setText("Calculation");

        jButton1.setText("Reload");
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        jLabel1.setText("Reload Builds From File");

        jButton4.setText("Go");
        jButton4.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton4ActionPerformed(evt);
            }
        });

        jTextArea1.setColumns(20);
        jTextArea1.setRows(5);
        jScrollPane1.setViewportView(jTextArea1);

        jCheckBoxBBB.setText("Best Caster Burst Build (useless)");

        jLabel4.setText("Calculate values of Items");

        jCheckBoxBBADLS.setSelected(true);
        jCheckBoxBBADLS.setText("Best Build Ad LifeSteal");

        jCheckBoxBBTAD.setSelected(true);
        jCheckBoxBBTAD.setText("Best Build Tanky Ad");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel3Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 710, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jLabel1)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jButton1)
                                .addGap(2, 2, 2))
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel3))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jButton3)
                                    .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 67, javax.swing.GroupLayout.PREFERRED_SIZE))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel13)
                        .addGap(23, 23, 23)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jCheckBoxBBTAD)
                            .addComponent(jCheckBoxBBADLS)
                            .addGroup(jPanel3Layout.createSequentialGroup()
                                .addComponent(jCheckBoxBBAD)
                                .addGap(67, 67, 67)
                                .addComponent(jCheckBoxBBB)))))
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1)
                    .addComponent(jButton1)
                    .addComponent(jCheckBoxBBAD)
                    .addComponent(jCheckBoxBBB)
                    .addComponent(jLabel13))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jCheckBoxBBADLS)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jCheckBoxBBTAD)
                    .addComponent(jButton3)
                    .addComponent(jLabel3))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 292, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(28, Short.MAX_VALUE))
        );

        jTabbedPane2.addTab("Calculation", jPanel3);

        jButton2.setText("annuler");
        jButton2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton2ActionPerformed(evt);
            }
        });

        jButton5.setText("sauver");
        jButton5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton5ActionPerformed(evt);
            }
        });

        jLabel2.setText("RatioDmgForTanky");

        jLabel5.setText("RatioTankyForTanky");

        jLabel6.setText("ArmorOfTank");

        jLabel7.setText("ArmorOfCarry");

        jLabel8.setText("Dps");

        jLabel9.setText("BurstDps");

        jLabel10.setText("CoefReducMaxAmrAndRm");

        jButton6.setText("charger");
        jButton6.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton6ActionPerformed(evt);
            }
        });

        jLabel11.setText("MinimumLS");

        jLabel12.setText("MinimumDPS");

        javax.swing.GroupLayout jPanel4Layout = new javax.swing.GroupLayout(jPanel4);
        jPanel4.setLayout(jPanel4Layout);
        jPanel4Layout.setHorizontalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jButton2))
                    .addGroup(jPanel4Layout.createSequentialGroup()
                        .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel12)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addComponent(jLabel11)
                                .addGap(85, 85, 85)
                                .addComponent(jTextField8))
                            .addGroup(jPanel4Layout.createSequentialGroup()
                                .addGap(0, 0, Short.MAX_VALUE)
                                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel6)
                                        .addGap(71, 71, 71)
                                        .addComponent(jTextField3))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel7)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                                        .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel8)
                                        .addGap(117, 117, 117)
                                        .addComponent(jTextField5))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel9)
                                        .addGap(92, 92, 92)
                                        .addComponent(jTextField6))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel2)
                                        .addGap(44, 44, 44)
                                        .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel5)
                                        .addGap(36, 36, 36)
                                        .addComponent(jTextField2))
                                    .addGroup(jPanel4Layout.createSequentialGroup()
                                        .addComponent(jLabel10)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jTextField7)))))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 464, Short.MAX_VALUE)
                        .addComponent(jButton6)))
                .addContainerGap())
        );
        jPanel4Layout.setVerticalGroup(
            jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel4Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jButton6))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel5)
                    .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel8)
                    .addComponent(jTextField5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextField6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jTextField7, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel11)
                    .addComponent(jTextField8, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel12)
                    .addComponent(jTextField9, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 185, Short.MAX_VALUE)
                .addGroup(jPanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jButton2)
                    .addComponent(jButton5))
                .addContainerGap())
        );

        jTabbedPane2.addTab("Options", jPanel4);

        jButton7.setText("Generate");
        jButton7.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton7ActionPerformed(evt);
            }
        });

        jTextArea2.setColumns(20);
        jTextArea2.setEditable(false);
        jTextArea2.setRows(5);
        jScrollPane3.setViewportView(jTextArea2);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel1Layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(jButton7))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 710, Short.MAX_VALUE))
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addGap(45, 45, 45)
                .addComponent(jButton7)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 371, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane2.addTab("TankyAdList", jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 69, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jButton6ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton6ActionPerformed
        jTextField1.setText("" + Parameters.ratioDmgForTrankyAd);
        jTextField2.setText("" + Parameters.ratioTankyForTrankyAd);
        jTextField3.setText("" + Parameters.armorOfTank);
        jTextField4.setText("" + Parameters.armorOfCarry);
        jTextField5.setText("" + Parameters.dps);
        jTextField6.setText("" + Parameters.dpsForBurst);
        jTextField7.setText("" + Parameters.coefReducMax);
        jTextField8.setText("" + Parameters.minimumLS);
        jTextField9.setText("" + Parameters.minimumDPS);
    }//GEN-LAST:event_jButton6ActionPerformed

    private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed
        try {
            Parameters.ratioDmgForTrankyAd = Float.parseFloat(jTextField1.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.armorOfTank = Integer.parseInt(jTextField3.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.ratioTankyForTrankyAd = Float.parseFloat(jTextField2.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.armorOfCarry = Integer.parseInt(jTextField4.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.dps = Integer.parseInt(jTextField5.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.dpsForBurst = Integer.parseInt(jTextField6.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.coefReducMax = Float.parseFloat(jTextField7.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.minimumDPS = Float.parseFloat(jTextField9.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
        try {
            Parameters.minimumLS = Integer.parseInt(jTextField8.getText());
        } catch (Exception e) {
            System.out.println("wtf");
        }
    }//GEN-LAST:event_jButton5ActionPerformed

    private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed
        try {
            CalculateValueOfAdItems cvad = new CalculateValueOfAdItems();
            CalculateValueOfApItems cvap = new CalculateValueOfApItems();
            cvad.start();
            cvap.start();
            cvap.join();
            cvad.join();
            jTextArea1.setText(cvad.resultToPrint + "\n\n" + cvap.resultToPrint);
        } catch (InterruptedException ex) {
            Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton4ActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        Thread t=new Thread() {
            @Override
            public void run() {
                try {
                    System.out.println("reading file, plz wait this might take a while...");
                    for (int j=0;j<=100;j++) {
                        ObjectInputStream inputStream = new ObjectInputStream(new FileInputStream("toto"+j+".bin"));
                        builds.addAll((ArrayList<Build>) inputStream.readObject());
                        inputStream.close();
                        jLabel13.setText(j+"%");
                    }
                    jLabel13.setText("chargé");
                } catch (Exception ex) {
                    Logger.getLogger(ItemBuildGeneratorFromFile.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        };
        t.start();
        
    }//GEN-LAST:event_jButton1ActionPerformed

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        try {
            String result = "";
            Build bestBuildAd = null;
            Build bestBuildAp = null;
            Build bestBuildTankyAd = null;
            Build bestBuildAdLifeSteal = null;
            /*
             * ArrayList<BestBuildCalculationThread> tasks=new
             * ArrayList<BestBuildCalculationThread>(); tasks.add(new
             * BestBuildCalculationThread()); tasks.add(new
             * BestBuildCalculationThread()); tasks.add(new
             * BestBuildCalculationThread()); tasks.add(new
             * BestBuildCalculationThread()); int dispoT=4; int actual=0;
             *
             */
            if (bestBuildAd == null) {
                bestBuildAd = builds.get(0);
            }
            if (bestBuildAp == null) {
                bestBuildAp = builds.get(0);
            }
            if (bestBuildTankyAd == null) {
                bestBuildTankyAd = builds.get(0);
            }
            if (bestBuildAdLifeSteal == null) {
                bestBuildAdLifeSteal = builds.get(0);
            }
            BBadLifeStealThread blst = null;
            BBadThread badt = null;
            BBapThread bapt = null;
            BBtadThread btadt = null;
            //init phase
            if (jCheckBoxBBTAD.isSelected()) {
                btadt = new BBtadThread(builds, bestBuildTankyAd);
                btadt.start();
            }
            if (jCheckBoxBBADLS.isSelected()) {
                blst = new BBadLifeStealThread(builds, bestBuildAdLifeSteal);
                blst.start();

            }

            if (jCheckBoxBBAD.isSelected()) {
                badt = new BBadThread(builds, bestBuildAd);
                badt.start();
            }

            if (jCheckBoxBBB.isSelected()) {
                bapt = new BBapThread(builds, bestBuildAp);
                bapt.start();
            }




            //joining

            if (jCheckBoxBBAD.isSelected()) {
                badt.join();
                bestBuildAd = badt.bestBuild;
            }
            if (jCheckBoxBBB.isSelected()) {
                bapt.join();
                bestBuildAp = bapt.bestBuild;
            }
            if (jCheckBoxBBADLS.isSelected()) {
                blst.join();
                bestBuildAdLifeSteal = blst.bestBuild;
            }
            if (jCheckBoxBBTAD.isSelected()) {
                btadt.join();
                bestBuildTankyAd = btadt.bestBuild;
            }

            DummyChamp g = null;
            try {
                g = Parameters.champUsedForAd.getClass().newInstance(); //new GenericChamp();/*new Jax();*/
            } catch (InstantiationException ex) {
                Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
            }
            BuildOrderCalculator bo = new BuildOrderCalculator(bestBuildAd);

            if (jCheckBoxBBAD.isSelected()) {
                bo.start();


                bestBuildAd.applyThisBuild(g);
                g.calculateAllDatas();
                g.printAllDatas();
                result += "best DpsBuild : " + bestBuildAd + "\n";
                try {
                    bo.join();
                } catch (InterruptedException ex) {
                    Logger.getLogger(ItemBuildGenerator.class.getName()).log(Level.SEVERE, null, ex);
                }
                Build buildOrderedAd = new Build();
                buildOrderedAd.items.addAll(bo.result.items);
                result += "price of build : " + bestBuildAd.getPriceOfBuild()+"\n";
                result += "best build ad ordered : " + buildOrderedAd + "\n\n";

            }
            if (jCheckBoxBBB.isSelected()) {
                DummyChamp c = null;
                try {
                    c = Parameters.champUsedForAp.getClass().newInstance();
                } catch (InstantiationException ex) {
                    Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
                } catch (IllegalAccessException ex) {
                    Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
                }
                bestBuildAp.applyThisBuild(c);
                c.calculateAllDatas();
                c.printAllDatas();
                result += "price of build : " + bestBuildAp.getPriceOfBuild()+"\n";
                result += "best burst : " + bestBuildAp + "\n\n";
            }

            if (jCheckBoxBBTAD.isSelected()) {
                g.resetStats();
                bestBuildTankyAd.applyThisBuild(g);
                g.calculateAllDatas();
                g.printAllDatas();
                result += "tanky score : " + ItemBuildGenerator.scoreCalculation(g.dpsOver100sec, g.timeToDie) + "\n";
                result += "best tankyAd : " + bestBuildTankyAd + "\n";
                bo = new BuildOrderCalculator(bestBuildTankyAd);
                bo.start();
                result += "price of build : " + bestBuildTankyAd.getPriceOfBuild()+"\n";
                result += "will now calculate best order for tanky dps" + "\n";
                try {
                    bo.join();
                } catch (InterruptedException ex) {
                    Logger.getLogger(ItemBuildGenerator.class.getName()).log(Level.SEVERE, null, ex);
                }
                Build buildOrderedTankyAd = new Build();
                buildOrderedTankyAd.items.addAll(bo.result.items);
                result += "best build Tanky ad ordered : " + buildOrderedTankyAd + "\n\n";

            }
            if (jCheckBoxBBADLS.isSelected()) {
                g.resetStats();
                bestBuildAdLifeSteal.applyThisBuild(g);
                g.calculateAllDatas();
                g.printAllDatas();
                result += "price of build : " + bestBuildAdLifeSteal.getPriceOfBuild()+"\n";
                result += "best AdLs : " + bestBuildAdLifeSteal + "\n\n";
            }
            this.jTextArea1.setText(result);
        } catch (InterruptedException ex) {
            Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_jButton3ActionPerformed

    private void jButton7ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton7ActionPerformed
        ArrayList<Duo<DummyChamp,Build>> champs=new ArrayList<Duo<DummyChamp,Build>>();
        for (Build b : builds) {
            DummyChamp dc=null;
            try {
                dc=Parameters.champUsedForAd.getClass().newInstance();
            } catch (InstantiationException ex) {
                Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IllegalAccessException ex) {
                Logger.getLogger(AppliGraphique.class.getName()).log(Level.SEVERE, null, ex);
            }
            b.applyThisBuild(dc);
            dc.calculateAllDatas();
            if (dc.canResistBigBurst) champs.add(new Duo<DummyChamp,Build>(dc,b));
        }
        Collections.sort(champs);
        int i=0;
        jTextArea2.setText("");
        while (i<100) {
            Duo<DummyChamp,Build> db=champs.get(i);
            jTextArea2.setText(jTextArea2.getText()+""+db.b.toString()+" "+ItemBuildGenerator.scoreCalculation(db.a.dpsOver100sec, db.a.timeToDie)+"\n");
            i++;
        }
        
    }//GEN-LAST:event_jButton7ActionPerformed

    private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
        jButton6ActionPerformed(evt);
    }//GEN-LAST:event_jButton2ActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        RunesCompoCalculator.main(args);
        BestDpsMasteriesChoose.main(args);
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(AppliGraphique.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(AppliGraphique.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(AppliGraphique.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(AppliGraphique.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                AllItems.populate();
            
                new AppliGraphique().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JButton jButton5;
    private javax.swing.JButton jButton6;
    private javax.swing.JButton jButton7;
    private javax.swing.JCheckBox jCheckBoxBBAD;
    private javax.swing.JCheckBox jCheckBoxBBADLS;
    private javax.swing.JCheckBox jCheckBoxBBB;
    private javax.swing.JCheckBox jCheckBoxBBTAD;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel12;
    private javax.swing.JLabel jLabel13;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JPanel jPanel4;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JTabbedPane jTabbedPane2;
    private javax.swing.JTextArea jTextArea1;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextField jTextField1;
    private javax.swing.JTextField jTextField2;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextField5;
    private javax.swing.JTextField jTextField6;
    private javax.swing.JTextField jTextField7;
    private javax.swing.JTextField jTextField8;
    private javax.swing.JTextField jTextField9;
    // End of variables declaration//GEN-END:variables
}
